package jicheng;

import java.util.Arrays;
import java.util.List;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xx.jicheng.entity.Category;
import com.xx.jicheng.mapper.CategoryMapper;

public class UpdateCategoryAttr {
	
	
	public static void main(String[] args) throws JsonProcessingException {
		ObjectMapper mapper = new ObjectMapper();
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring.xml");
		CategoryMapper categoryMapper = context.getBean(CategoryMapper.class);
		List<Category> list = categoryMapper.find3s();
		for(Category c: list) {
//			System.out.println(c.getName());
			List<String> names = categoryMapper.findAttrNames(c.getName());
			System.out.println(names);
			String attr = mapper.writeValueAsString(names);
			c.setAttr(attr);
			categoryMapper.update(c);
		}
		context.close();
	}

}
